package com.motorwaymanage.impl;

import java.io.IOException;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.motorwaymanage.beans.CheckInfo;
import com.motorwaymanage.biz.ICheckInfoBiz;
import com.motorwaymanage.dao.DBAccess;

public class CheckInfoBizImpl implements ICheckInfoBiz{
	private DBAccess db=new DBAccess();
	
	@Override
	public List<CheckInfo> selectCheckInfo() {
		SqlSession session=null;
		List<CheckInfo> list=null;
		try {
			session=db.getSqlSession();
			ICheckInfoBiz checkInfoBiz=session.getMapper(ICheckInfoBiz.class);
			list=checkInfoBiz.selectCheckInfo();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return list;
	}
	
	@Override
	public int addCheckInfo(CheckInfo ci) {
		SqlSession session=null;
		int result=0;
		try {
			session=db.getSqlSession();
			ICheckInfoBiz checkInfoBiz=session.getMapper(ICheckInfoBiz.class);
			result=checkInfoBiz.addCheckInfo(ci);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}

	@Override
	public int delCheckInfo(int cid) {
		SqlSession session=null;
		int result=0;
		try {
			session=db.getSqlSession();
			ICheckInfoBiz checkInfoBiz=session.getMapper(ICheckInfoBiz.class);
			result=checkInfoBiz.delCheckInfo(cid);
			session.commit();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			session.close();
		}
		return result;
	}
	
}
